package com.bwie.controller;

import com.bwie.mapper.TbProdMapper;
import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.Result;
import com.bwie.vo.ProdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author: zhaijiaqi
 * @Date: 2025/5/27 09:38
 * @Description:
 **/
@RestController
@RequestMapping("/shop/prod")
public class TbprodController {

    @Autowired
    TbProdService tbProdService;


    /**
     * 产品列表
     * @return
     */
    @PostMapping("/ProdList")
    public Result ProdList(@RequestBody ProdPageVo prodPageVo){
      return tbProdService.ProdList(prodPageVo);
    }

    /**
     * 添加商品
     * @param tbProd
     * @return
     */
    @PostMapping("/AddProd")
    public Result AddProd(@RequestBody TbProd tbProd){
        return tbProdService.AddProd(tbProd);
    }

    /**
     * 上传商品图片
     * @param file
     * @return
     */
    @PostMapping("/UpProdImage")
    public Result UpProdImage(@RequestPart("file")MultipartFile file){
        return tbProdService.UpProdImage(file);
    }

    /**
     * 批量删除
     * @return
     */
    @PostMapping("/DeleteAll")
    public Result DeleteAll(@RequestBody List<TbProd> tbProdList){
        return tbProdService.DeleteAll(tbProdList);
    }

    /**
     * 修改商品
     * @return
     */
    @PostMapping("/UpdataProd")
    public Result UpdataProd(@RequestBody TbProd tbProd){
        return tbProdService.UpdataProd(tbProd);
    }
}
